package net.melon.uploader;

import java.text.DecimalFormat;

public class UploadCounter {

	private long fileSize;
	private long currentSize;
	
	public UploadCounter(long fileSize) {
		super();
		this.fileSize = fileSize;
	}
	
	public long getFileSize() {
		return fileSize;
	}
	public void setFileSize(long fileSize) {
		this.fileSize = fileSize;
	}
	public long getCurrentSize() {
		return currentSize;
	}
	public void setCurrentSize(long currentSize) {
		this.currentSize = currentSize;
	}
	
	public String getPercent(){
		double d =  (currentSize / (fileSize* 1.0)) * 100.0;
		DecimalFormat df = new DecimalFormat("##.00");
		return df.format(d);
	}
	
	public boolean getFinish(){
		boolean b = (currentSize >= fileSize&&fileSize!=0);
		if(b){
			currentSize = 0;
			fileSize = 0;
		}
		return b;
	}
}
